<template>
	<view style="padding: 5px;background-color: #fff;">
		<view style="position: relative;margin-bottom: 5px;">
			<view @click="show2=true"><u-input readonly placeholder="选择指定领导任务" v-model="leaderName" /></view>
			<view style="    display: flex;
			justify-content: center;
			position: absolute;
			height: 100%;
			width: 38px;
			right: 0px;
			top: 0px;
			border-left: 1px solid #dadbde;"><u-icon name="arrow-down-fill"></u-icon></view>
			<!-- <u-picker :show="show2" :columns="leaderData" @confirm="confirmPicker" @cancel="cancelPicker" keyName="name"> </u-picker> -->
			<multiplePicker title="工作人员" :show="show2" :columns="multiplePickerData" @confirm="confirmPicker"
				@cancel="show2 = false">
			</multiplePicker>
		</view>
		<!-- 日期选择 -->
		<view style="margin-bottom: 5px;" class="myDatePicker">
			<uni-datetime-picker :show="show" type="daterange" @change="confirmDate"
				@cancel="cancelDate"></uni-datetime-picker>
		</view>
		<view style="padding-bottom: 5px;">
			<uni-segmented-control :current="current" :values="fv" @clickItem="onClickItem" styleType="button"
				activeColor="#007aff"></uni-segmented-control>
		</view>
		<view style="padding-bottom: 5px;">
			<u-button color="#007aff" @click="addRow" style="background-color: #007aff;">新增</u-button>
		</view>
	</view>

	<!-- 	<view class="myFab">
		<uni-fab :pattern="pattern" :content="content" horizontal="left" vertical="top" direction="horizontal"
			:popMenu="true" @trigger="trigger" @fabClick="fabClick" />
	</view> -->

	<view style="padding: 0px 0px 10px 0px;background-color: #fff;">
		<scroll-view scroll-y="true" show-scrollbar="true">
			<uni-list :border="true">
				<view v-for="item in indexData">
					<u-cell class="note-container" clickable :avatarShow="false" :clickable="true">
						<template v-slot:title>
							<view style="display: flex;">
								<view
									style="display: flex;justify-content: center;align-items: center;margin-right: 2px;margin-left: 1px;">
									<view v-if="item.readFlag==0" style="background-color: #007aff;width: 10px;height: 10px;border-radius: 20px;">
									</view>
									<view v-else style="width: 10px;height: 10px;border-radius: 20px;">
									</view>
								</view>
								<view style="display: flex;flex-direction: column;">
									<text style="    font-size: 16px;
									color: #3b4144;
									font-weight: normal;
									overflow: hidden;
									white-space: nowrap;
									    text-overflow: ellipsis;
									    width: 20vw;">{{item.title}}</text>
									<text style="margin-top: 3px;
										color: #999;
										font-size: 12px;
										font-weight: normal;
										overflow: hidden;">{{item.content}}</text>

								</view>
							</view>
						</template>
						<template v-slot:value>


							<view style="display: flex;">
								<view style="display: flex;" @click="listClick(item)">
									<text class="sn">{{item.leaderTaskStartDate}}至{{item.leaderTaskEndDate}}</text>
									<view>
										<view class="chat-custom-right">
											<view>
												<text
													:class="item.status === 0 ? 'Mgreen' : 'Mred'">{{item.status==1?"未完成":"已完成"}}</text>
											</view>

											<text class="ck">查看内容</text>
										</view>


									</view>

								</view>
								<view style="margin-left: 5px;">
									<u-button type="error" @click="delRow(item)">删除</u-button>
								</view>
							</view>
						</template>
					</u-cell>
				</view>
			</uni-list>
		</scroll-view>
	</view>

	<view>
		<uni-popup ref="popup" background-color="#fff">
			<view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">
				<scroll-view scroll-y="true" class="mycss-max-height85">
					<uni-row>
						<uni-col>
							<view class="mycss-flex-around mycss-title-bg">
								<view class="uni-ma-5">
									<text>{{openTitle}}</text>
								</view>
							</view>
						</uni-col>
					</uni-row>
					<u-collapse>
						<u--form labelWidth="200" labelPosition="top" ref="form" :rules="addRules" :model="add">
							<uni-card title="领导选择">


								<u-collapse-item title="表格选择" name="Docs guide">
									<DaTree ref="DaTreeRef" :data="roomTreeData" labelField="name" valueField="id"
										defaultExpandAll showCheckbox @change="handleTreeChange"></DaTree>
								</u-collapse-item>


								<view class="uni-container">
									<view class="uni-ma-3">
										<uni-easyinput prefixIcon="search" v-model="searchValue" placeholder="请输入员姓名"
											@iconClick="searchName">
										</uni-easyinput>
									</view>
									<uni-table :loading="loading" border stripe emptyText="暂无更多数据">
										<uni-tr>
											<uni-th align="center">操作</uni-th>
											<uni-th align="center">账号</uni-th>
											<uni-th align="center">姓名</uni-th>
											<uni-th align="center">所属部门</uni-th>
										</uni-tr>
										<uni-tr v-for="(item,index) in tableData" :key="index">
											<uni-td width="150" align="center">
												<view class="my-btn">
													<u-button type="primary" size="mini"
														v-if="this.leaderSelectIdList.indexOf(item.id)==-1"
														@click="getLeaderName(item)">选择</u-button>
													<u-button type="error" size="mini"
														v-if="this.leaderSelectIdList.indexOf(item.id)>-1"
														@click="delLeaderName(item)">移除</u-button>
												</view>
											</uni-td>
											<uni-td width="150" align="center">
												<view>
													{{item.account}}
												</view>
											</uni-td>
											<uni-td width="150" align="center">
												<view>
													{{item.name}}
												</view>
											</uni-td>
											<uni-td width="200" align="center">
												<view>
													{{item.departNames}}
												</view>
											</uni-td>
										</uni-tr>
									</uni-table>
									<view class="uni-mb-5 uni-mt-5">
										<uni-pagination :total="total" :pageSize="params.size" prev-text="前一页"
											next-text="后一页" @change="doChangePage" />
									</view>
								</view>
								<view>

									<u-form-item label="领导" borderBottom prop="addLeaderName">
										<u-input disabled disabledColor="#fff" border="none" placeholder="请输入内容"
											v-model="add.addLeaderName"></u-input>
									</u-form-item>
								</view>
							</uni-card>

							<uni-card title="领导布置的任务信息">
								<view>
									<u-form-item label="任务标题" borderBottom prop="addTitleName">
										<u-input  placeholder="请输入内容" v-model="add.addTitleName"></u-input>
									</u-form-item>
									<u-form-item label="任务内容" borderBottom prop="addContentName">
										<u-input  placeholder="请输入内容"
											v-model="add.addContentName"></u-input>
									</u-form-item>
									<u-form-item label="项目起始日期" borderBottom prop="addDateName">
										<uni-datetime-picker :show="show" type="daterange" @cancel="cancelDate"
											v-model="add.addDateName"></uni-datetime-picker>
									</u-form-item>
									<u-form-item label="状态" borderBottom>
										<u-switch v-model="add.addSwitch"></u-switch>
									</u-form-item>
									<u-form-item label="星极" borderBottom>
										<uni-rate v-model="add.addLevel"></uni-rate>
									</u-form-item>
									<u-form-item label="任务工序" borderBottom style="width: 100%;">
										<view style="width: 86.6vw;">
											<process-bar ref="addleaderWkRef" :day="50" :list="add.addleaderWk"
												:showTop="false"></process-bar>
										</view>
									</u-form-item>
								</view>
							</uni-card>
							<uni-card title="下属汇报的信息">
								<view>
									<u-form-item label="任务内容" borderBottom prop="addSubContent">
										<u-input  placeholder="请输入内容"
											v-model="add.addSubContent"></u-input>
									</u-form-item>
									<!-- <u-form-item label="任务进度" borderBottom prop="addSubProgress">
										<u-slider v-model="add.addSubProgress"  :disabled="true"></u-slider>
									</u-form-item> -->
									<u-form-item label="任务工序" borderBottom prop="addleaderWk">
										<view style="width: 86.6vw;">
											<process-bar :day="50" :list="add.addSubWk" ref="addSubWkRef"></process-bar>
										</view>
									</u-form-item>
								</view>


							</uni-card>
						</u--form>
					</u-collapse>

					<u-button type="primary" @click="addAllAddFrom">保存</u-button>
					<u-button @click="delAllAddFrom">清空</u-button>

				</scroll-view>
			</view>
		</uni-popup>
	</view>
	<!-- 详情页面 -->
	<view>
		<uni-popup ref="textPopup" background-color="#fff">
			<view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">
				<scroll-view scroll-y="true" class="mycss-max-height85">
					<uni-row>
						<uni-col>
							<view class="mycss-flex-around mycss-title-bg">
								<view class="uni-ma-5">
									<text>{{openTitle}}</text>
								</view>
							</view>
						</uni-col>
					</uni-row>
					<u-collapse>
						<u--form labelWidth="200" labelPosition="top" ref="form" :rules="textRules" :model="text">
							<uni-card title="领导选择">
								<u-form-item label="领导" borderBottom>
									<u-input  v-model="text.textLeaderName" disabled
										disabledColor="#fff"></u-input>
								</u-form-item>
							</uni-card>
							<uni-card title="领导布置的任务信息">
								<view>
									<u-form-item label="任务标题" borderBottom prop="textTitleName">
										<u-input  placeholder="请输入内容"
											v-model="text.textTitleName"></u-input>
									</u-form-item>
									<u-form-item label="任务内容" borderBottom prop="textContentName">
										<u-input  placeholder="请输入内容"
											v-model="text.textContentName"></u-input>
									</u-form-item>

									<u-form-item label="项目起始日期" borderBottom prop="textDateName">
										<uni-datetime-picker :show="show" type="daterange" @cancel="cancelDate"
											v-model="text.textDateName"></uni-datetime-picker>
									</u-form-item>
									<u-form-item label="状态" borderBottom prop="textSwitch">
										<u-switch v-model="text.textSwitch"></u-switch>
									</u-form-item>
									<u-form-item label="星极" borderBottom prop="textSwitch">
										<uni-rate v-model="text.textLevel"></uni-rate>
									</u-form-item>
									<u-form-item label="任务工序" borderBottom prop="textSwitch">
										<view style="width: 86.6vw;">
											<process-bar :day="50" :list="text.textleaderWk" ref="textLeaderWkRef"
												:showTop="false"></process-bar>

										</view>
									</u-form-item>
								</view>



							</uni-card>
							<uni-card title="下属汇报的信息">

								<view>
									<u-form-item label="任务内容" borderBottom prop="textSubContent">
										<u-input  placeholder="请输入内容"
											v-model="text.textSubContent"></u-input>
									</u-form-item>
									<!-- 	<u-form-item label="任务进度" borderBottom prop="textSubProgress">
										<u-slider v-model="text.textSubProgress" :disabled="true"></u-slider>
									</u-form-item> -->
									<u-form-item label="任务工序" borderBottom prop="textSwitch">
										<view style="width: 86.6vw;">
											<process-bar :day="50" :list="text.textSubWk"
												ref="textSubWkRef"></process-bar>
										</view>
									</u-form-item>
								</view>


							</uni-card>
						</u--form>
					</u-collapse>
					<u-button type="primary" @click="addAllTextFrom">保存</u-button>
					<u-button @click="delAllTextFrom">清空</u-button>
				</scroll-view>
			</view>
		</uni-popup>
	</view>
	<!-- 弹框消息 -->
	<u-toast ref="uToast"></u-toast>
	<!-- 加载中 -->
	<u-loadmore :status="status" height="50px" />
</template>
<script>
	import DaTree from '@/components/da-tree/index.vue';
	import ProcessBar from '@/components/process-bar/process-bar.vue'
	import multiplePicker from '@/components/multiple-picker/multiple-picker.vue';
	export default {
		components: {
			DaTree,
			multiplePicker,
			ProcessBar,
		},
		data() {
			return {
				status: 'loadmore', //下加载条状态
				loading: false, //表格加载中
				multiplePickerData: [],
				leaderData: [],
				uSlider: 0,
				uniRate: 0,
				uSwitch: 0,
				total: 0,
				tableData: [],
				params: {
					page: 1,
					size: 10,
				},
				roomTreeData: "",
				current: 0,
				openTitle: "新增",
				delButtonFlag: true,
				show: false,
				show2: false,
				leaderName: null,
				value1: Date.now(),
				fv: ["全部", "已读", "未读"],
				indexData: [],
				pattern: {
					color: '#7A7E83',
					backgroundColor: '#fff',
					selectedColor: '#007AFF',
					buttonColor: '#007AFF',
					iconColor: '#fff'
				},
				queryParams: { //查询条件
					page: 1,
					size: 10,
					readFlag: "",
					relateType: "leader",
				},
				type: {
					type: 'leader'
				},
				add: {
					addLeaderName: "",
					addTitleName: "",
					addContentName: "",
					addDateName: [],
					addSwitch: true,
					addSubProgress: 20,
					addLevel: 1,
					addSubContent: "",
					addleaderWk: [],
					addSubWk: [],
				},
				addRules: {
					'addTitleName': {
						type: 'string',
						required: true,
						message: '请填写标题',
						trigger: ['blur', 'change']
					},
					'addContentName': {
						type: 'string',
						required: true,
						message: '请填写内容',
						trigger: ['blur', 'change']
					},
					'addSubContent': {
						type: 'string',
						required: true,
						message: '请填写内容',
						trigger: ['blur', 'change']
					},

				},
				text: {
					textLeaderName: "",
					textTitleName: "",
					textContentName: "",
					textDateName: ["2020-01-01", "2020-01-02"],
					textSwitch: true,
					textSubProgress: 20,
					textLevel: 1,
					textSubContent: "",
					addleaderWk: [],
					addSubWk: [],
				},
				textDateNameFlag: true,
				textRules: {
					'textTitleName': {
						type: 'string',
						required: true,
						message: '请填写标题',
						trigger: ['blur', 'change']
					},
					'textContentName': {
						type: 'string',
						required: true,
						message: '请填写内容',
						trigger: ['blur', 'change']
					},
					'textSubContent': {
						type: 'string',
						required: true,
						message: '请填写内容',
						trigger: ['blur', 'change']
					},

				},
				textFrom: {
					subProgress: 0, //进度
				},
				addFrom: {
					memberIds: "", //进度
				},
				searchValue: "",
				leaderSelectIdList: [], //新增时领导选择的id数组
				leaderSelectNameList: [], //新增时领导选择的id数组
			}
		},
		methods: {
			doChangePage(e) {
				this.loading = true;
				this.params.page = e.current;
				this.$http.post("/depart/getUsersEx", this.params).then((res) => {
					if (res && res.data && res.data.code == 1) {
						console.log(res);
						this.tableData = res.data.rows;
						this.total = res.data.total;
						this.loading = false;
					}
				}).catch((re) => {
					loading.value = false;
				});
			},
			confirmDate(e) {
				console.log(e);
				if (e == []) {
					this.textDateNameFlag = false;
				} else {
					this.textDateNameFlag = true;
				}
				this.value1 = e.value;
				this.queryParams.leaderTaskStartDate = e[0];
				this.queryParams.leaderTaskEndDate = e[1];
				console.log(this.queryParams);
				this.queryParams.page = 1;
				this.initTableData();
			},
			cancelDate() {
				this.show = false
			},
			confirmPicker(e) {
				var list = []
				for (var i = 0; i < this.multiplePickerData.length; i++) {
					console.log(e.value);
					console.log(this.multiplePickerData[i].value);
					if (e.value.includes(this.multiplePickerData[i].value)) {
						list.push(this.multiplePickerData[i].label)
					}
				}
				this.leaderName = list.map(item => item.toString()).join(',');
				this.show2 = false
				console.log(this.leaderName);
				console.log(e.value.map(item => item.toString()).join(','));
				this.queryParams.leaderId = e.value.map(item => item.toString()).join(',');
				this.queryParams.page = 1;
				this.initTableData()
			},
			cancelPicker() {
				this.show2 = false
			},
			addRow() {
				console.log("点击了新增");
				this.openTitle = "新增"
				this.$refs.popup.open("bottom")
			},
			delRow(val) {
				console.log("点击了删除", val);
				var myThis = this;
				uni.showModal({
					title: '提示',
					content: '是否删除',
					success: function(but) {
						if (but.confirm) {
							console.log('用户点击确定', val.id);
							myThis.dele(val.id);
						} else if (but.cancel) {
							console.log('用户点击取消')

						}
					}
				})


			},
			dele(val) {
				console.log("123");
				console.log("删除");
				this.$http.post("/leaderTask/dele", {
					id: val
				}).then((res) => {
					console.log("123", res);
					if (res && res.data.code == 1) {
						this.$refs.uToast.show({
							title: "删除成功",
							type: 'success',
							message: "删除成功",
							iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/loading.png'
						})
					} else {
						this.$refs.uToast.show({
							title: "删除失败！",
							type: 'error',
							message: "删除失败！",
							iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/error.png'
						})
					}
					this.queryParams.page = 1;
					this.initTableData()
				});
			},
			initTableData() {
				console.log(this.queryParams);
				this.$http.post("/leaderTask/table", this.queryParams).then((res) => {
					console.log("123", res.data.rows);
					if (res && res.data.code == 1) {
						console.log("123", res);
						this.indexData = res.data.rows;
						console.log(res.data.rows.length);
						if (res.data.rows.length < 10) {
							this.status = "nomore";
						}
					}
				});
			},
			pageChange(e) {
				console.log(e);
			},
			onClickItem(e) {
				console.log(e.currentIndex);
				if (e.currentIndex == 0) {
					this.queryParams.readFlag = '';
				} else if (e.currentIndex == 1) {
					this.queryParams.readFlag = 1;
				} else if (e.currentIndex == 2) {
					this.queryParams.readFlag = 0;
				};
				this.queryParams.page = 1;
				this.initTableData()
			},
			listClick(val) {
				console.log("mas", val.id);
				console.log("leaderWk", val.leaderWk);
				this.$http.post('/leaderTask/detail', {
					id: val.id
				}).then(res => {
					console.log(res.data.data);
					var mas = res.data.data;
					console.log("mas", mas);

					this.text.textleaderWk = mas.leaderWk;
					this.text.textSubWk = mas.subWk;

					console.log("this.text.textleaderWk", this.text.textleaderWk);
					console.log("this.text.textSubWk", this.text.textSubWk);
					this.textData = mas;
					//设置领导名字展示
					this.text.textLeaderName = mas.leader.name;
					this.text.textTitleName = mas.title;
					this.text.textContentName = mas.content;
					this.text.textDateName = [mas.leaderTaskStartDate, mas.leaderTaskEndDate];
					this.text.textSwitch = mas.status == 0 ? false : true;
					this.text.textSubProgress = mas.subProgress;
					this.text.textLevel = mas.level;
					this.text.textSubContent = mas.subContent;
					this.openTitle = "详情"
					console.log("this.text.textLevel ", this.text);
					this.$refs.textPopup.open("bottom")
				})

			},
			//详情页面清空
			delAllTextFrom() {
				// this.text.textLeaderName = "";
				this.text.textTitleName = "";
				this.text.textContentName = "";
				this.text.textDateName = "";
				this.text.textSwitch = false;
				this.text.textSubProgress = 0;
				this.text.textLevel = 0;
				this.text.textSubContent = "";
				this.text.textleaderWk = [];
				this.text.textSubWk = [];
			},
			//编辑
			addAllTextFrom() {
				console.log(this.$refs.textSubWkRef.processHandler());
				console.log(this.$refs.textSubWkRef.processHandler().arr);
				console.log(this.$refs.textLeaderWkRef.processHandler().arr);

				this.textFrom.leaderWk = this.$refs.textLeaderWkRef.processHandler().arr; //领导工序
				this.textFrom.subWk = this.$refs.textSubWkRef.processHandler().arr; //下属工序

				this.textFrom.LeaderTaskEndDate = this.text.textDateName[1],
					this.textFrom.LeaderTaskStartDate = this.text.textDateName[0],
					this.textFrom.completeTime = this.textData.completeTime,
					this.textFrom.content = this.text.textContentName,
					this.textFrom.id = this.textData.id,

					this.textFrom.level = this.text.textLevel,
					this.textFrom.memberIds = "",
					this.textFrom.status = this.text.textSwitch ? 1 : 0,
					this.textFrom.subContent = this.text.textSubContent,
					this.textFrom.subProgress = this.$refs.textSubWkRef.processHandler().value2,
					this.textFrom.title = this.text.textTitleName,
					this.textFrom.type = "leader",
					this.textFrom.readFlag = 1,

					console.log(this.textFrom);

				this.$http.post('/leaderTask/edit', this.textFrom, 'json')
					.then(response => {
						console.log('请求成功:', response.data);
						if (response.data.code == 0) {
							// this.$refs.textPopup.close()
							this.$refs.uToast.show({
								title: "编辑失败,请填写内容！",
								type: 'error',
								message: "编辑失败,请填写内容！",
								iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/error.png'
							})
						} else if (response.data.code == 1) {
							this.$refs.textPopup.close() //关闭弹窗

							//消息提示
							this.$refs.uToast.show({
								title: "编辑成功",
								type: 'success',
								message: "编辑成功",
								iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/loading.png'
							})
							this.queryParams.page = 1;
							this.initTableData();
						}

						// 处理响应数据
					})
					.catch(error => {
						console.error('请求失败:', error);
						this.$refs.textPopup.close()
						this.$refs.uToast.show({
							title: "编辑失败",
							type: 'error',
							message: "编辑失败",
							iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/error.png'
						})
					});
			},
			//添加时领导筛选
			handleTreeChange(allSelectedKeys, currentItem) {
				this.loading = true;
				console.log('handleTreeChange ==>', allSelectedKeys, currentItem)
				this.params.id = allSelectedKeys.map(item => item.toString()).join(',')
				this.$http.post("/depart/getUsersEx", this.params).then((res) => {
					console.log("res.data", res.data);
					if (res && res.data && res.data.code == 1) {
						this.tableData = res.data.rows;
						this.total = res.data.total;
					}
					this.loading = false;
				}).catch(() => {});
			},
			delLeaderName(val) {
				for (let i = this.leaderSelectIdList.length - 1; i >= 0; i--) {
					if (this.leaderSelectIdList[i] === val.id) {
						this.leaderSelectIdList.splice(i, 1);
					}
				}
				this.addFrom.memberIds = this.leaderSelectIdList.map(item => item.toString()).join(',')
				console.log(this.leaderSelectNameList.map(item => item.toString()).join(','));

				for (let i = this.leaderSelectNameList.length - 1; i >= 0; i--) {
					if (this.leaderSelectNameList[i] == val.name) {
						console.log("删除------");
						this.leaderSelectNameList.splice(i, 1);
					}
				}
				console.log(this.leaderSelectNameList.map(item => item.toString()).join(','));
				this.add.addLeaderName = this.leaderSelectNameList.map(item => item.toString()).join(',')
			},
			getLeaderName(val) {
				console.log("val", val);
				this.leaderSelectNameList.push(val.name);
				this.add.addLeaderName = this.leaderSelectNameList.map(item => item.toString()).join(',')

				this.leaderSelectIdList.push(val.id);
				this.addFrom.memberIds = this.leaderSelectIdList.map(item => item.toString()).join(',')
			},
			//姓名查找
			searchName() {
				this.params.name = this.searchValue;
				this.$http.post("/depart/getUsersEx", this.params).then((res) => {
					if (res && res.data && res.data.code == 1) {
						this.tableData = res.data.rows;
						this.total = res.data.total;
					}
				}).catch((re) => {});
			},
			delAllAddFrom() {
				console.log("清空");
				this.add.addLeaderName = "";
				this.add.addTitleName = "";
				this.add.addContentName = "";
				this.add.addDateName = "";
				this.add.addSwitch = false;
				this.add.addSubProgress = 0;
				this.add.addLevel = 0;
				this.add.addSubContent = "";
				this.add.addleaderWk = [];
				this.add.addSubWk = [];
				this.leaderSelectIdList = [];
				console.log(this.add.addleaderWk);
				console.log(this.$refs.addSubWkRef.processHandler());

			},
			addAllAddFrom() {
				console.log(this.$refs.addleaderWkRef.processHandler());
				this.add.addleaderWk = this.$refs.addleaderWkRef.processHandler().arr;
				this.add.addSubWk = this.$refs.addSubWkRef.processHandler().arr;
				console.log("添加", this.add.addleaderWk);
				console.log("添加", this.add.addSubWk);
				console.log(this.addFrom.memberIds);
				// console.log(this.add.memberIds);
				this.addFrom.LeaderTaskStartDate = this.add.addDateName[0],
					this.addFrom.LeaderTaskEndDate = this.add.addDateName[1],
					this.addFrom.content = this.add.addContentName,
					this.addFrom.leaderWk = this.add.addleaderWk, //领导工序
					this.addFrom.subWk = this.add.addSubWk, //下属工序
					this.addFrom.level = this.add.addLevel,
					this.addFrom.status = this.add.addSwitch ? 1 : 0,
					this.addFrom.subContent = this.add.addSubContent,
					this.addFrom.subProgress = this.$refs.addSubWkRef.processHandler().value2,
					this.addFrom.title = this.add.addTitleName,
					this.addFrom.type = "leader",
					console.log(this.addFrom);

				this.$http.post('/leaderTask/edit', this.addFrom, 'json')
					.then(response => {
						console.log('请求成功:', response.data);
						if (response.data.code == 0) {
							// this.$refs.textPopup.close()
							this.$refs.uToast.show({
								title: "新增失败,请填写内容！",
								type: 'error',
								message: "新增失败,请填写内容！",
								iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/error.png'
							})
						} else if (response.data.code == 1) {
							this.$refs.popup.close("bottom")

							//消息提示
							this.$refs.uToast.show({
								title: "新增成功",
								type: 'success',
								message: "新增成功",
								iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/loading.png'
							})
							this.delAllAddFrom();
							this.queryParams.page = 1;
							this.initTableData();
						}

						// 处理响应数据
					})
					.catch(error => {
						console.error('请求失败:', error);
						this.$refs.Popup.close()
						this.$refs.uToast.show({
							title: "新增成功",
							type: 'error',
							message: "新增成功",
							iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/error.png'
						})
					});
			},
			//滚动调用
			scroll() {
				this.status = "loading";
				this.queryParams.page++;
				console.log("滚动调用1", this.queryParams);
				this.$http.post("/leaderTask/table", this.queryParams).then((res) => {
					if (res && res.data.code == 1) {
						console.log("123", res);
						this.indexData = this.indexData.concat(res.data.rows);
						console.log(res.data);
						if (res.data.rows.length <= 0) {
							this.status = "nomore";
						}
					}
				});
			}

		},
		mounted() {
			this.initTableData();
			this.$http.post("/depart/getAll").then((res) => {
				if (res.data.code == 1) {
					this.roomTreeData = res.data.data;
				}
			}).catch((re) => {
				console.log("re", re)
			});

			this.$http.post("/depart/getUsersEx", this.params).then((res) => {
				console.log(res.data.rows);
				if (res && res.data && res.data.code == 1) {
					this.tableData = res.data.rows;
					// loading.value = false;
					console.log("this.tableData", this.tableData);
				}
			}).catch((re) => {
				// loading.value = false;
			});
			//获取领导内容
			this.$http.post("/leaderTask/relatePersonalList", this.type).then((res) => {
				if (res && res.data.code == 1) {
					var list = []
					for (var i = 0; i < res.data.data.length; i++) {
						var aa = {};
						aa.label = res.data.data[i].name;
						aa.value = res.data.data[i].id;
						list.push(aa)
					}

					this.leaderData = res.data.data;
					this.multiplePickerData = list;
				}
			});

		}
	}
</script>
<style>
	.top-layout-left {
		margin-right: 10px;
	}

	.top-layout {
		border: 1px solid #d5d5d5;
		display: flex;
		align-items: center;
		height: 40px;
		padding-left: 5px;
		margin-bottom: 10px
	}

	.list {
		/* border: 1px solid #d5d5d5; */
		display: flex;
		align-items: center;
		height: 50px;
		padding-left: 5px;
		margin-bottom: 10px;
	}




	.ck {
		margin-top: 3px;
		color: #999;
		font-size: 11px;
		font-weight: normal;
	}

	.sn {
		color: #999;
		font-size: 11px;
		font-weight: normal;
		margin-right: 5px;
		margin-top: 3px;
	}

	.note-container {
		overflow: hidden;
		/* 隐藏溢出内容 */
		text-overflow: ellipsis;
		/* 使用省略号来表示被隐藏的内容 */
		white-space: nowrap;
		/* 防止内容换行，保持在一行显示 */
	}

	.chat-custom-right {
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: flex-end;
	}

	.Mgreen {
		color: #008000;
	}

	.Mred {
		color: #ff0000;
	}
</style>